<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm"  :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="医院名称" prop="hospitalName">
        <el-input
            v-model="queryParams.hospitalName"
            placeholder="请输入医院名称"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="医院编号" align="center" prop="hospitalId" />
      <el-table-column label="医院名称" align="center" prop="hospitalName" />
      <el-table-column prop="doctorCount" label="医师人数" align="center" />
      <el-table-column prop="numberOfConsultations" label="问诊次数" align="center" />
<!--      <el-table-column prop="positiveFeedbackRate" label="好评度" align="center" />-->

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">

          <el-button link type="primary"  @click="access(scope.row.hospitalId)">进入</el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />
  </div>
</template>

<script setup name="AdministrativeOffice">
import {listTable} from "@/api/manage/AdministrativeOffice";

const { proxy } = getCurrentInstance();

const tableList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const route = useRoute();
const router = useRouter();

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    hospitalName: null,
  },
  rules: {
  }
});

const { queryParams, form, rules } = toRefs(data);

function access(hospitalId){
  router.push({path:'/manage/PhysicianManagement',query:{hospitalId:hospitalId}});
}

    /** 查询医院管理列表 */
   function getList() {
      loading.value = true;
      listTable(data.queryParams).then(response => {
        console.log(response)
        tableList.value = response.data.rows;
        total.value = response.data.total;
        loading.value = false;
      });
    }
    /** 搜索按钮操作 */
   function handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    }
// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.hospitalId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}


getList();
</script>
